window.onload=function getPageInformation() {

    let login_name = localStorage.getItem("loginName");
    window.localStorage.setItem("page","1");
    if(login_name==="游客"){
        window.location.href="../html/Login.html";
        alert("游客请登录")
    }
    else {
        new Vue({
            el: "#be_follow",
            data() {
                return {
                    be_follow: []
                }
            },
            mounted() {
                let _this = this;
                ajax({
                    type: "post",
                    url: "../../follow",
                    data: {
                        loginName: login_name,
                        code: 0
                    },
                    success: function (result) {
                        console.log(result);
                        _this.be_follow = result["beFollow"];
                    },
                    error: function () {
                        alert("粉丝数据读取失败");
                    }
                })
            }
        })

        new Vue({
            el: "#follow",
            data() {
                return {
                    follow: []
                }
            },
            mounted() {
                let _this = this;
                ajax({
                    type: "post",
                    url: "../../follow",
                    data: {
                        loginName: login_name,
                        code: 1
                    },
                    success: function (result) {
                        console.log(result);
                        _this.follow = result["follow"];
                    },
                    error: function () {
                        alert("粉丝数据读取失败");
                    }
                })
            }
        })

        new Vue({
            el:"#information",
            data(){
                return{
                    informations:[]
                }
            },
            mounted() {
                let _this = this;
                ajax({
                    type: "post",
                    url: "../../user",
                    data: {
                        userName: login_name,
                        code: 0
                    },
                    success: function (result) {
                        console.log(result);
                        _this.informations = result;
                    },
                    error: function () {
                        alert("个人信息数据读取失败");
                    }
                })
            }
        })
    }

}

function add_name() {
    let login_name = localStorage.getItem("loginName");
    let new_name=document.getElementById("name").value;
    window.localStorage.setItem("loginName",new_name);
    ajax({
        type: "post",
        url: "../../user",
        data: {
            userName: login_name,
            name:new_name,
            code: 2
        },
        success: function (result) {
            console.log(result);
        },
        error: function () {
            alert("更改数据读取失败");
        }
    })
}

function add_email() {
    let login_name = localStorage.getItem("loginName");
    let new_email=document.getElementById("email").value;
    ajax({
        type: "post",
        url: "../../user",
        data: {
            userName: login_name,
            email:new_email,
            code: 1
        },
        success: function (result) {
            console.log(result);
        },
        error: function () {
            alert("更改数据读取失败");
        }
    })
}
